package com.house.twohouse.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.house.twohouse.config.CrawlerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.house.twohouse.entity.RecordEntity;
import com.house.twohouse.service.RecordService;
import com.house.common.utils.PageUtils;
import com.house.common.utils.R;



/**
 * 
 *
 * @author wzh
 * @email sunlightcs@gmail.com
 * @date 2022-04-25 20:50:10
 */
@RestController
@RequestMapping("twohouse/record")
@SuppressWarnings("all")
public class RecordController {
    @Autowired
    private RecordService recordService;

    @Autowired
    private CrawlerConfig crawlerConfig;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = recordService.queryPage(params);

        return R.ok().put("page", page);
    }



    /**
     * 调用爬虫工具类
     */
    @RequestMapping("/save")
    public R save() throws Exception {
        List<RecordEntity> recordEntityList = crawlerConfig.secondCrawlerAdd();
        recordService.saveBatch(recordEntityList);
        return R.ok();
    }

}
